<?php 
include('../common/common.php');
include('../common/checksession.php');
checksession("../index.php");
include('../../inc/conn.php');

$restore_id=$_POST["beach_restore"];
$gurl=$_SERVER['HTTP_REFERER'];

foreach($restore_id as $v){
	isnum($v,"操作失败!",$gurl);
}
$restore_id=implode(",",$restore_id);

$db=db_connect();
$sql=select_sql("`isdel`","`".PRETABLE."arcmain`","id in(".$restore_id.")");
$rs=$db->query($sql) or die("datebase error!");
$temp=1;
	while($row=$rs->fetch_assoc()){
		if($row['isdel']!=1){$temp=0;}
	}
if($temp){
$db->query('SET AUTOCOMMIT=0'); // 设置为不自动提交查询 
$db->query('START TRANSACTION'); // 开始查询，这里也可以使用B
$sql_main="DELETE FROM `".PRETABLE."arcmain` WHERE `id` in(".$restore_id.")";
$sql_arc="DELETE FROM `".PRETABLE."article` WHERE `aid` in(".$restore_id.")";

if(!$db->query($sql_main)){
	ShowMsg("操作失败！",$gurl);
	exit;
	}
	
$db->query($sql_arc);
if($db->affected_rows<0){
	$db->query('ROLLBACK');//如果遇到错误数据回滚
	ShowMsg("操作失败!",$gurl);	
	$db->query('COMMIT');
	$rs->close();
	$db->close();
	exit;
}
$db->query('COMMIT');
$rs->close();
$db->close();
ShowMsg_h("操作成功!",$gurl);	
}else{
ShowMsg("操作失败!",$gurl);
$rs->close();
$db->close();
exit;
}


?>